package com.tyl.xtk.beans.dto;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.tyl.xtk.config.validation.groups.Insert;
import com.tyl.xtk.config.validation.groups.Update;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Pattern;
import lombok.Data;
import org.hibernate.validator.constraints.Length;

/**
 * create by tyl at 2025/8/27
 */
@Data
@Schema(description = "用户信息")
public class UserPutDto {
    @NotNull(groups = Update.class, message = "id is required")
    @Schema(description = "id")
    private Long id;

    @NotNull(groups = Insert.class, message = "用户名必须填写")
    @Length(min = 2, max = 16, message = "用户名长度应为2-16")
    @Schema(description = "用户名")
    private String username;

    @Schema(description = "密码")
    @JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
    @NotNull(groups = Insert.class, message = "密码必须填写")
    @Length(min = 6, max = 20, message = "密码长度应为6-20")
    private String password;

    @Schema(description = "邮箱", example = "aaa@aaa.com")
    @Pattern(regexp = "^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}$", message = "邮箱格式不正确")
    private String email;
    
    @Schema(description = "手机号")
    @Pattern(regexp = "^1[3-9]\\d{9}$", message = "手机号格式不正确")
    private String phone;
}